//////////////////////////////////////////////////
// glVertexBO.h
//
// Author: Tarik Belabbas et Adrien Hoffer
//////////////////////////////////////////////////

#ifndef GLVERTEXBO_H_
#define GLVERTEXBO_H_

// Required to use VBOs (glGenBuffers() & co)
// and must be defined BEFORE including glext.h (included by QtOpenGL)
#define GL_GLEXT_PROTOTYPES

#include <GL/gl.h>
//#include <vector>
#include <QDebug>
#include <algorithm>
#include "../common/Common.h"

#define BUFFER_OFFSET( _i )	( ( char* )NULL + ( _i ) )

//------------------------------------------------------------------------------
class glVertexBO
{
public:
	glVertexBO	();
	~glVertexBO	();

	void			genBuffer		();

	void			bindBuffer		( GLenum _target );
	void			unbindBuffer	( GLenum _target );

	void			storeData		( GLenum _target, GLenum _usage,
										const void* _pointer, unsigned int _size );
	void*			mapBuffer		( GLenum _target, GLenum _access );
	GLboolean		unmapBuffer		( GLenum _target );

	GLint			getBufferName	()	const	{ return m_bufferName; }

	void			swap			( glVertexBO& _other )	{ std::swap( m_bufferName, _other.m_bufferName ); }

private:
	// Members
	GLint				m_bufferName;
};

#endif /* GLVERTEXBO_H_ */
